package com.zengqingfa.thread.demo4;

import java.util.ArrayList;
import java.util.List;

/**
 * @fileName: UnsafeList
 * @author: zengqf3
 * @date: 2020-10-7 19:28
 * @description:
 */
public class UnsafeList {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(() -> {
                list.add(Thread.currentThread().getName());
            }).start();
        }
        //9998 当两个线程操作同一个位置时会进行覆盖
        System.out.println(list.size());
    }
}
